package two;

class Course {
    String id;
    String name;
    String location;
    String time;
    String teacherName;

    public Course(String id, String name, String location, String time, String teacherName) {
        this.id = id;
        this.name = name;
        this.location = location;
        this.time = time;
        this.teacherName = teacherName;
    }

    public String toString() {
        return "课程编号：" + id + " | 课程名称：" + name + " | 上课地点：" + location +
                " | 上课时间：" + time + " | 授课教师：" + teacherName;
    }
}

class Student {
    String id;
    String name;
    Course[] courses;
    int courseCount;

    public Student(String id, String name) {
        this.id = id;
        this.name = name;
        this.courses = new Course[10];
        this.courseCount = 0;
    }

    public void selectCourse(Course course) {
        courses[courseCount] = course;
        courseCount++;
    }

    public void dropCourse(String courseId) {
        Course[] newCourses = new Course[10];
        int newCount = 0;

        for (int i = 0; i < courseCount; i++) {
            if (!courses[i].id.equals(courseId)) {
                newCourses[newCount] = courses[i];
                newCount++;
            }
        }
        courses = newCourses;
        courseCount = newCount;
    }

    public void printCourseTable() {
        System.out.println("========== " + name + " 的课表 ==========");
        if (courseCount == 0) {
            System.out.println("暂无课程");
        } else {
            for (int i = 0; i < courseCount; i++) {
                System.out.println(courses[i]);
            }
        }
        System.out.println("=====================================");
    }
}

public class Choose {
    static void main(String[] args) {
        Course course1 = new Course("C001", "Java程序设计", "A101", "周一 8:00-10:00", "张老师");
        Course course2 = new Course("C002", "数据库原理", "B202", "周三 14:00-16:00", "李老师");
        Course course3 = new Course("C003", "计算机网络", "C305", "周五 10:00-12:00", "王老师");

        Student student = new Student("S001", "小明");

        student.selectCourse(course1);
        student.selectCourse(course2);
        student.selectCourse(course3);

        System.out.println("=== 选课后的课表 ===");
        student.printCourseTable();

        student.dropCourse("C002");

        System.out.println("=== 退课后的课表 ===");
        student.printCourseTable();
    }
}